home *** CD-ROM | disk | FTP | other *** search
/ Web Designer 98 (Professional) / WebDesigner 1.0.iso / tutorials / tutorial / navigate.txt < prev    next >
Encoding:
Text File  |  1997-06-15  |  1.4 KB  |  62 lines

  1. #!/usr/bin/perl
  2. #
  3. # navigate.pl
  4. # version 961117
  5. # copyright 1996 by bo larsson
  6. # all rights reserved
  7. #
  8. # bugs or feedback to bliss@seagull.net
  9. # for information on how to use, visit http://www.seagull.net/bliss/
  10. # <FORM METHOD=POST action="http://www.seagull.net/bliss/cgi/navigate.pl">
  11. # <INPUT TYPE=HIDDEN NAME="Alta Vista" VALUE="http://www.altavista.digital.com/">
  12. # <INPUT TYPE=HIDDEN NAME="Lycos" VALUE="http://www.lycos.com/">
  13. # <INPUT TYPE=HIDDEN NAME="Yahoo" VALUE="http://www.yahoo.com/">
  14. #
  15. # <TABLE BORDER=1 CELLPADDING=5 ALIGN=CENTER BGCOLOR="#FFFFFF"><TR><TD>
  16. #
  17. # <B>Take me to </B>
  18. # <SELECT NAME="where">
  19. #        <OPTION> Alta Vista
  20. #        <OPTION> Lycos
  21. #        <OPTION> Yahoo
  22. # </SELECT>
  23. # <INPUT TYPE="SUBMIT" VALUE="Do It!">
  24.  
  25. $ten_twenty = "";
  26.  
  27. # Get the input and strip off all unwanted characters
  28. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  29. $temp = $buffer;
  30. $temp =~ s/\+/ /g;
  31. $temp =~ s/%([0-9|A-F]{2})/pack(C,hex($1))/eg;
  32.  
  33. # Store the matching name and value pairs
  34. foreach (split(/&/,$temp))
  35. {
  36.     ($NAM, $VAL) = split(/=/, $_);
  37.     $DATA{$NAM} = $VAL;
  38.     $valist .= "$NAM=$VAL\n";
  39. }
  40.  
  41. # Grab necessary variable
  42. $where = $DATA{'where'};
  43.  
  44. foreach (split(/\n/,$valist))
  45. {
  46.     ($the_place,$the_url) = split(/=/, $_);
  47.     if ($where eq $the_place)
  48.     {
  49.         $ten_twenty = $the_url;
  50.     }
  51. }
  52.  
  53. if ($ten_twenty ne "")
  54. {
  55.     print("location:$ten_twenty\n\n");
  56. }
  57. else
  58. {
  59.     print "Content-type: text/plain\n\n";
  60.     print "You want to go somewhere I don't understand!";
  61. }
  62.